<?php

namespace app\common\model;

use think\Model;

class OrderModel extends Model
{
    protected $table = 'orders';
    protected $autoWriteTimestamp = 'timestamp';

    /**
     * 用户
     * @return \think\model\relation\BelongsTo
     * @author zws
     */
    public function user()
    {
        return $this->belongsTo('UserModel', 'user_id', 'id');
    }

    /**
     * 充电桩
     * @return \think\model\relation\BelongsTo
     * @author zws
     */
    public function charge()
    {
        return $this->belongsTo('ChargingModel', 'charge_id', 'id');
    }

    public function instrument()
    {
        return $this->belongsTo('InstrumentModel', 'instrument_id', 'id');
    }

    public function detection(){
        return $this->hasMany("DetectionModel", "order_id", "id");
    }

    public function orderParam(){
        return $this->hasOne('OrderParamModel', 'order_id', 'id');
    }
    public function orderImage(){
        return $this->hasMany('OrderImageModel', 'order_id', 'id');
    }

    public function  orderProject()
    {
        return $this->hasMany('OrderProjectModel', 'order_id', 'id');
    }

}
